{extend name="../../public/admin"}
{block name="title"}添加数据{/block}
{block name="css"}{/block}
{block name="body"}
<div class="container" id="data" v-cloak>
    <div style="height: 15px;"></div>
    <ul class="nav nav-tabs">
        <li :class="{'active':type == 0}"><a href="javascript:;" @click="type=0">添加用户组</a></li>
        <li :class="{'active':type == 1}"><a href="javascript:;" @click="type=1">添加管理员</a></li>
    </ul>
    <div style="height: 15px;"></div>
    {/*添加用户组*/}
    <form action="{:url('user/add_admin')}" method="post" v-show="type == 0" class="form">
        <div class="form-group input-group bg-label">
            <label class="input-group-addon">学校名称</label>
            <input type="text" name="name" class="form-control" datatype="s1-20" ajaxurl="{:url('user/is_admin_group')}">
        </div>
        <div class="form-group input-group bg-label">
            <label class="input-group-addon">学校代码</label>
            <input type="text" name="remark" class="form-control" datatype="*">
        </div>
        <div class="form-group text-center">
            <button class="btn btn-info">{:lang('立即添加')}</button>
        </div>
    </form>
    {/*添加管理员*/}
    <form action="{:url('user/add_admin')}" method="post" v-show="type == 1" class="form">
        <div class="form-group input-group bg-label">
            <label class="input-group-addon">用户组</label>
            <select name="groupId" class="form-control"  datatype="*">
                <option value="">请选择</option>
                <template v-for="key in adminGroup">
                    <option :value="key.id">{{key.name}}</option>
                </template>
            </select>
        </div>
        <div class="form-group input-group bg-label">
            <label class="input-group-addon">账&nbsp;&nbsp;&nbsp;号</label>
            <input type="text" name="account" class="form-control" datatype="s1-20" ajaxurl="{:url('user/is_admin')}">
        </div>
        <div class="form-group input-group bg-label">
            <label class="input-group-addon">密&nbsp;&nbsp;&nbsp;码</label>
            <input type="text" name="password" class="form-control" datatype="s1-20">
        </div>
        <div class="form-group input-group bg-label">
            <label class="input-group-addon">姓&nbsp;&nbsp;&nbsp;名</label>
            <input type="text" name="name" class="form-control" datatype="s1-20">
        </div>
        <div class="form-group input-group bg-label">
            <label class="input-group-addon">备&nbsp;&nbsp;&nbsp;注</label>
            <input type="text" name="remark" class="form-control" datatype="s1-20">
        </div>
        <div class="form-group text-center">
            <button class="btn btn-info">{:lang('立即添加')}</button>
        </div>
    </form>
</div>
{/block}
{block name="js"}
<link rel="stylesheet" href="__PUBLIC__/public/validform/style.css">
<script src="__PUBLIC__/public/validform/Validform_v5.3.2_min.js"></script>
<script>
    (()=>{
        var app = new Vue({
            el:'#data',
            data:{
                type:0,
                adminGroup:[]
            }
        });
        $.post(DUSER+'/index',{name:'group'},function (da) {
            app.adminGroup = da;
        })

        $('.form').Validform({
            tiptype:4,
            ajaxPost:true,
            callback:function (da) {
                if(da == 1){
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                }
                else{
                    layer.msg('添加失败',{icon:2});
                }
            }
        });
    })();
</script>
{/block}